#!/bin/sh

text=$(cat $1 | tr -d [:punct:] | tr [:space:] \\n | sed '/^$/d')
while [ -n "$text" ]
do
  word=$(echo $text | awk '{print $1;}')
  echo "$word\t\t\t" $(echo "$text" | grep -ic "^$word$")
  text=$(echo "$text" | sed "s/^$word$//gI")
done
